package com.cyk.comicforumjava.demos.enits;

import com.cyk.comicforumjava.demos.utils.IdProcess;
import lombok.Data;

import java.time.LocalDateTime;

@Data
public class Message {
    private String id;
    private String content;
    private LocalDateTime createTime;
    private Long userlId;
    private Long senderId;
    private String senderName;
    private String userName;
    private String kind;
    private boolean isRead;

    public Message(){
        this.id = IdProcess.generateMessageId();
    }

    public Message(Post post){
        this.id = IdProcess.generateMessageId();
        this.content = post.getPostContent();
        this.createTime = post.getTime();
        this.userlId = post.getPostMaster();
        this.kind="post";
        this.isRead=false;
    }

    public Message(Comment comment){
        this.id = IdProcess.generateMessageId();
        if(comment.getParentId()!=null&& comment.getParentId().substring(0,1).equals("C")){
            this.content="<p>"+comment.getUserName()+"回复了你</p>"+comment.getContent();
            this.kind="backComment";
        }else{
            this.content = "<p>"+comment.getUserName()+"评论了你</p>"+comment.getContent();
            this.kind="comment";
        }

        this.createTime = comment.getCommentTime();

        this.isRead=false;
    }
    public Message(Support support ){
        this.id = IdProcess.generateMessageId();
        this.senderId=support.getUserId();
        this.createTime = LocalDateTime.now();
        this.kind="support";
        this.isRead=false;
    }


}
